package com.myidis.controller;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.myidis.entity.QuotaData;
import com.myidis.response.QuotaDataRes;
import com.myidis.servlet.QuotaDataServlet;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

@Controller
@RequestMapping("/data")
@Api(tags = "指标数据相关接口")
public class QuotaDataController {

	@Autowired
	private QuotaDataServlet dataServlet;
	
	@ResponseBody
	@RequestMapping("/list")
	@ApiOperation("获取所有指标数据")
	public List<QuotaDataRes> deptList() {
		return dataServlet.all();
	}
	
	@ResponseBody
	@RequestMapping("/entity")
	@ApiOperation("获取一个指标数据")
	public QuotaData one(@RequestBody QuotaData data) {
		return dataServlet.getOne(data.getId());
	}
	
	@ResponseBody
	@RequestMapping("/add")
	@ApiOperation("添加一个指标数据")
	public int add(@RequestBody QuotaData data) {
		return dataServlet.insert(data);
	}
	
	@ResponseBody
	@RequestMapping("/addAll")
	@ApiOperation("添加一组指标数据")
	public int addAll(@RequestBody List<QuotaData> datas) {
		return dataServlet.insertAll(datas);
	}
	
	@ResponseBody
	@RequestMapping("/upd")
	@ApiOperation("修改一个指标数据")
	public int upd(@RequestBody QuotaData datas) {
		return dataServlet.update(datas);
	}

	@ResponseBody
	@RequestMapping("/del")
	@ApiOperation("删除一个指标数据")
	public int del(@RequestBody int id) {
		return dataServlet.delete(id);
	}
	
	@ResponseBody
	@RequestMapping("/delAll")
	@ApiOperation("删除一组指标数据")
	public int delAll(@RequestBody int[] ids) {
		return dataServlet.deleteAll(ids);
	}
}